package com.cspg.design.presenter;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.cspg.design.CSPGApplication;
import com.cspg.design.MainActivity;
import com.cspg.design.adapter.Style;
import com.cspg.design.bean.UserInfo;
import com.cspg.design.bean.shemeBean.MyHighVoltageSchemeBean;
import com.cspg.design.bean.shemeBean.MyLowVoltageSchemeBean;
import com.cspg.design.dao.gen.DaoSession;
import com.cspg.design.dto.MyHighVoltageSchemeDto;
import com.cspg.design.dto.MyLowVoltageSchemeDto;
import com.cspg.design.request.DeviceLibrary;
import com.cspg.design.request.Scheme;
import com.cspg.design.ui.login.LoginActivity;
import com.cspg.design.ui.schemeActivity.MyHighVoltageSchemeEditActivity;
import com.cspg.design.ui.schemeActivity.MySchemeActivity;
import com.cspg.design.widget.CSPGProgressBar;
import com.cspg.design.widget.Loading;
import com.cspg.design.widget.ToastUtils;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.List;

import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;

public class SchemePresenter implements IPresenter {
    private final Scheme schemeModel;
    private final Activity activity;

    private final DaoSession daoSession;

    private CSPGProgressBar cspgProgressBar;

    private MyHighVoltageSchemeDto myHighVoltageSchemeDto;
    private MyLowVoltageSchemeDto myLowVoltageSchemeDto;

    private final ListView lvHighVoltage;
    private final ListView lvLowVoltage;
    private List<MyHighVoltageSchemeBean> myHighVoltageSchemeBeanList;
    private List<MyLowVoltageSchemeBean> myLowVoltageSchemeBeanList;
    private TextView tvNoData;
    private final DeviceLibrary deviceLibrary;

    public SchemePresenter(Activity activity,ListView lvHighVoltage, ListView lvLowVoltage) {
        this.schemeModel = new Scheme(this);
        this.activity = activity;
        this.daoSession = ((CSPGApplication)activity.getApplication()).getDaoSession();
        this.lvHighVoltage = lvHighVoltage;
        this.lvLowVoltage = lvLowVoltage;

        deviceLibrary = new DeviceLibrary(daoSession);
        deviceLibrary.requestPoleLibrary();
        deviceLibrary.requestTransformerLibrary();
        deviceLibrary.requestWireLibrary();
    }

    public  void  getHighVoltageScheme()
    {
        if(cspgProgressBar == null)
        {
            cspgProgressBar = CSPGProgressBar.show(activity);
        }else {
            cspgProgressBar.show();
        }
        try {
            schemeModel.getHighVoltageScheme();
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public  void  getLowVoltageScheme()
    {
        if(cspgProgressBar == null)
        {
            cspgProgressBar = CSPGProgressBar.show(activity);
        }else {
            cspgProgressBar.show();
        }
        try {
            schemeModel.getLowVoltageScheme();
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }


    public void updateHighVoltageScheme(MyHighVoltageSchemeBean myHighVoltageSchemeBean)  {
        if(cspgProgressBar == null)
        {
            cspgProgressBar = CSPGProgressBar.show(activity);
        }else {
            cspgProgressBar.show();
        }
        try {
            MyHighVoltageSchemeDto myHighVoltageSchemeDto =  highBeanConverterToDto(myHighVoltageSchemeBean);
            this.myHighVoltageSchemeDto = myHighVoltageSchemeDto;
            schemeModel.updateHighVoltageScheme(myHighVoltageSchemeDto);
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void updateLowVoltageScheme(MyLowVoltageSchemeBean myLowVoltageSchemeBean)  {
        if(cspgProgressBar == null)
        {
            cspgProgressBar = CSPGProgressBar.show(activity);
        }else {
            cspgProgressBar.show();
        }
        try {
            MyLowVoltageSchemeDto myLowVoltageSchemeDto =  lowBeanConverterToDto(myLowVoltageSchemeBean);
            this.myLowVoltageSchemeDto = myLowVoltageSchemeDto;
            schemeModel.updateLowVoltageScheme(myLowVoltageSchemeDto);
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void addHighVoltageScheme(MyHighVoltageSchemeBean myHighVoltageSchemeBean)  {


        if(cspgProgressBar == null)
        {
            cspgProgressBar = CSPGProgressBar.show(activity);
        }else {
            cspgProgressBar.show();
        }
        try {
            MyHighVoltageSchemeDto myHighVoltageSchemeDto = highBeanConverterToDto(myHighVoltageSchemeBean);
            this.myHighVoltageSchemeDto = myHighVoltageSchemeDto;
            schemeModel.addHighVoltageScheme(myHighVoltageSchemeDto);
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void addLowVoltageScheme(MyLowVoltageSchemeBean myLowVoltageSchemeBean)  {
        if(cspgProgressBar == null)
        {
            cspgProgressBar = CSPGProgressBar.show(activity);
        }else {
            cspgProgressBar.show();
        }
        try {
            MyLowVoltageSchemeDto myLowVoltageSchemeDto = lowBeanConverterToDto(myLowVoltageSchemeBean);
            this.myLowVoltageSchemeDto = myLowVoltageSchemeDto;
            schemeModel.addLowVoltageScheme(myLowVoltageSchemeDto);
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void getFailure(String msg) {

        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
            cspgProgressBar.dismiss();
        }
        ToastUtils.toast(activity, msg);
    }

    public void getTokenExpireFailure() {

        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
            cspgProgressBar.dismiss();
        }
        Intent intent = new Intent();
        intent.setClass(activity, LoginActivity.class);
        activity.startActivity(intent);
    }

    public void requestHighSuccess(MyHighVoltageSchemeDto myHighVoltageSchemeDto) {
        if (myHighVoltageSchemeDto != null) {
            processHighData(myHighVoltageSchemeDto);
        }
    }

    public void requestHighSuccess(List<MyHighVoltageSchemeDto> myHighVoltageSchemeDtos) {
        if (myHighVoltageSchemeDtos != null) {
            processHighData(myHighVoltageSchemeDtos);
        }
    }

    public void updateHighSuccess() {
        MyHighVoltageSchemeDto myHighVoltageSchemeDto = this.myHighVoltageSchemeDto;
        if (myHighVoltageSchemeDto != null) {
            processHighData(myHighVoltageSchemeDto);
        }
    }
    public void requestLowSuccess(MyLowVoltageSchemeDto myLowVoltageSchemeDto) {
        if (myLowVoltageSchemeDto != null) {
            processLowData(myLowVoltageSchemeDto);
        }
    }

    public void requestLowSuccess(List<MyLowVoltageSchemeDto> myLowVoltageSchemeDtos) {
        if (myLowVoltageSchemeDtos != null) {
            processLowData(myLowVoltageSchemeDtos);
        }
    }

    public void updateLowSuccess() {
        MyLowVoltageSchemeDto myLowVoltageSchemeDto = this.myLowVoltageSchemeDto;
        if (myLowVoltageSchemeDto != null) {
            processLowData(myLowVoltageSchemeDto);
        }
    }

    @Override
    public void netWorkError(String netError) {

        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
            cspgProgressBar.dismiss();
        }
        ToastUtils.toast(activity, netError);
        if (activity instanceof MainActivity) {
            //activity.openNewActivity(LoginActivity.class);
            Intent intent = new Intent();
            intent.setClass(activity, LoginActivity.class);
            activity.startActivity(intent);
        }
    }

    @Override
    public void httpRequestFailure(String noDataError) {
        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
            cspgProgressBar.dismiss();
        }
        ToastUtils.toast(activity, noDataError);
        if (activity instanceof MainActivity) {
            //activity.openNewActivity(LoginActivity.class);
            Intent intent = new Intent();
            intent.setClass(activity, LoginActivity.class);
            activity.startActivity(intent);
        }
    }

    @Override
    public void httpRequestSuccess() {
        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
            cspgProgressBar.dismiss();
        }
    }
    private void processLowData(List<MyLowVoltageSchemeDto> myLowVoltageSchemeDtos)
    {
            daoSession.getMyLowVoltageSchemeBeanDao().deleteAll();
            daoSession.getMyLowVoltageSchemeBeanDao().rx().insertOrReplaceInTx(lowDtoConverterToBeans(myLowVoltageSchemeDtos)).observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new Action1<Iterable<MyLowVoltageSchemeBean>>() {
                        @Override
                        public void call(Iterable<MyLowVoltageSchemeBean> myLowVoltageSchemeBeanIterable) {
                            if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
                                cspgProgressBar.dismiss();
                            }
                            updateLowUI(myLowVoltageSchemeBeanIterable);
                        }
                    } );
    }
    private void processHighData(List<MyHighVoltageSchemeDto> myHighVoltageSchemeDtos)
    {
        daoSession.getMyHighVoltageSchemeBeanDao().deleteAll();
        daoSession.getMyHighVoltageSchemeBeanDao().rx().insertOrReplaceInTx(highDtoConverterToBeans(myHighVoltageSchemeDtos)).observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Iterable<MyHighVoltageSchemeBean>>() {
                    @Override
                    public void call(Iterable<MyHighVoltageSchemeBean> myHighVoltageSchemeBeans) {
                        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
                            cspgProgressBar.dismiss();
                        }
                        updateHighUI(myHighVoltageSchemeBeans);
                    }
                } );
    }

    private void processLowData(MyLowVoltageSchemeDto myLowVoltageSchemeDto)
    {
        daoSession.getMyLowVoltageSchemeBeanDao().rx().insertOrReplace(lowDtoConverterToBean(myLowVoltageSchemeDto)).observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<MyLowVoltageSchemeBean>() {
                    @Override
                    public void call(MyLowVoltageSchemeBean myLowVoltageSchemeBean) {
                        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
                            cspgProgressBar.dismiss();
                            ToastUtils.toast(activity,"操作成功。。。。");
                        }
                    }
                });
    }
    private void processHighData(MyHighVoltageSchemeDto myHighVoltageSchemeDto)
    {

        daoSession.getMyHighVoltageSchemeBeanDao().rx().insertOrReplace(highDtoConverterToBean(myHighVoltageSchemeDto)).observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<MyHighVoltageSchemeBean>() {
                    @Override
                    public void call(MyHighVoltageSchemeBean myHighVoltageSchemeBean) {
                        if (null != cspgProgressBar && cspgProgressBar.isShowing()) {
                            cspgProgressBar.dismiss();
                            ToastUtils.toast(activity,"操作成功。。。。");
                        }
                    }
                });
    }

    private List<MyHighVoltageSchemeBean> highDtoConverterToBeans(List<MyHighVoltageSchemeDto> myHighVoltageSchemeDtoList)
    {
        List<MyHighVoltageSchemeBean> myHighVoltageSchemeBeanList = new ArrayList<>();
        for (int i =0 ;i < myHighVoltageSchemeDtoList.size();i++)
        {
            if (myHighVoltageSchemeDtoList.get(i).getUserName().equals(UserInfo.getInstance().userName) || UserInfo.getInstance().role.contains("设计") )
            {
                myHighVoltageSchemeBeanList.add(highDtoConverterToBean(myHighVoltageSchemeDtoList.get(i)));
            }
        }
        return myHighVoltageSchemeBeanList;
    }

    private MyHighVoltageSchemeBean highDtoConverterToBean(MyHighVoltageSchemeDto myHighVoltageSchemeDto)
    {
        MyHighVoltageSchemeBean myHighVoltageSchemeBean = new MyHighVoltageSchemeBean() ;
        myHighVoltageSchemeBean.setSchemeId(myHighVoltageSchemeDto.getId());
        myHighVoltageSchemeBean.setSchemeUUID(myHighVoltageSchemeDto.getSchemeUUID());
        myHighVoltageSchemeBean.setSchemeName(myHighVoltageSchemeDto.getSchemeName());
        myHighVoltageSchemeBean.setVoltageLevel(myHighVoltageSchemeDto.getVoltageLevel());
        myHighVoltageSchemeBean.setWireModel(myHighVoltageSchemeDto.getWireModel());
        myHighVoltageSchemeBean.setTransformerModel(myHighVoltageSchemeDto.getTransformerModel());

        myHighVoltageSchemeBean.setFlatGround(myHighVoltageSchemeDto.getFlatGround()); //">平地</string>
        myHighVoltageSchemeBean.setHillyArea(myHighVoltageSchemeDto.getHillyArea()); //"山地</string>
        myHighVoltageSchemeBean.setHighMountain(myHighVoltageSchemeDto.getHighMountain()); //"高山</string>
        myHighVoltageSchemeBean.setHills(myHighVoltageSchemeDto.getHills()); //"丘陵</string>

        myHighVoltageSchemeBean.setCommonSoil(myHighVoltageSchemeDto.getCommonSoil()); //">普通土</string>
        myHighVoltageSchemeBean.setHardSoil(myHighVoltageSchemeDto.getHardSoil()); //"坚土</string>
        myHighVoltageSchemeBean.setLooseSandstone(myHighVoltageSchemeDto.getLooseSandstone()); //"松砂石</string>
        myHighVoltageSchemeBean.setMudPuddle(myHighVoltageSchemeDto.getMudPuddle()); //"泥水坑</string>
        myHighVoltageSchemeBean.setRock(myHighVoltageSchemeDto.getRock()); //"岩石</string>
        myHighVoltageSchemeBean.setTypicalDesignModel(myHighVoltageSchemeDto.getTypicalDesignModel()); //"典型设计模块</string>

        myHighVoltageSchemeBean.setUserName(myHighVoltageSchemeDto.getUserName());

        return myHighVoltageSchemeBean;
    }
    private MyHighVoltageSchemeDto highBeanConverterToDto(MyHighVoltageSchemeBean myHighVoltageSchemeBean)
    {
        MyHighVoltageSchemeDto myHighVoltageSchemeDto = new MyHighVoltageSchemeDto() ;
        myHighVoltageSchemeDto.setId(myHighVoltageSchemeBean.getSchemeId());
        myHighVoltageSchemeDto.setSchemeUUID(myHighVoltageSchemeBean.getSchemeUUID());
        myHighVoltageSchemeDto.setSchemeName(myHighVoltageSchemeBean.getSchemeName());
        myHighVoltageSchemeDto.setVoltageLevel(myHighVoltageSchemeBean.getVoltageLevel());
        myHighVoltageSchemeDto.setWireModel(myHighVoltageSchemeBean.getWireModel());
        myHighVoltageSchemeDto.setTransformerModel(myHighVoltageSchemeBean.getTransformerModel());

        myHighVoltageSchemeDto.setFlatGround(myHighVoltageSchemeBean.getFlatGround()); //">平地</string>
        myHighVoltageSchemeDto.setHillyArea(myHighVoltageSchemeBean.getHillyArea()); //"山地</string>
        myHighVoltageSchemeDto.setHighMountain(myHighVoltageSchemeBean.getHighMountain()); //"高山</string>
        myHighVoltageSchemeDto.setHills(myHighVoltageSchemeBean.getHills()); //"丘陵</string>

        myHighVoltageSchemeDto.setCommonSoil(myHighVoltageSchemeBean.getCommonSoil()); //">普通土</string>
        myHighVoltageSchemeDto.setHardSoil(myHighVoltageSchemeBean.getHardSoil()); //"坚土</string>
        myHighVoltageSchemeDto.setLooseSandstone(myHighVoltageSchemeBean.getLooseSandstone()); //"松砂石</string>
        myHighVoltageSchemeDto.setMudPuddle(myHighVoltageSchemeBean.getMudPuddle()); //"泥水坑</string>
        myHighVoltageSchemeDto.setRock(myHighVoltageSchemeBean.getRock()); //"岩石</string>
        myHighVoltageSchemeDto.setTypicalDesignModel(myHighVoltageSchemeBean.getTypicalDesignModel()); //"典型设计模块</string>

        myHighVoltageSchemeDto.setUserName(myHighVoltageSchemeBean.getUserName());

        return myHighVoltageSchemeDto;
    }
    private List<MyLowVoltageSchemeBean> lowDtoConverterToBeans(List<MyLowVoltageSchemeDto> myLowVoltageSchemeDtoList)
    {
        List<MyLowVoltageSchemeBean> myLowVoltageSchemeBeanList = new ArrayList<>();
        for (int i =0 ;i < myLowVoltageSchemeDtoList.size();i++)
        {
            if (myLowVoltageSchemeDtoList.get(i).getUserName().equals(UserInfo.getInstance().userName) || UserInfo.getInstance().role.contains("设计") )
            {
                myLowVoltageSchemeBeanList.add(lowDtoConverterToBean(myLowVoltageSchemeDtoList.get(i)));
            }
        }
        return myLowVoltageSchemeBeanList;
    }

    private MyLowVoltageSchemeBean lowDtoConverterToBean(MyLowVoltageSchemeDto myLowVoltageSchemeDto)
    {
        MyLowVoltageSchemeBean myLowVoltageSchemeBean = new MyLowVoltageSchemeBean() ;
        myLowVoltageSchemeBean.setSchemeId(myLowVoltageSchemeDto.getId());
        myLowVoltageSchemeBean.setSchemeUUID(myLowVoltageSchemeDto.getSchemeUUID());
        myLowVoltageSchemeBean.setSchemeName(myLowVoltageSchemeDto.getSchemeName());
        myLowVoltageSchemeBean.setWireModel380V(myLowVoltageSchemeDto.getWireModel380V());
        myLowVoltageSchemeBean.setWireModel220V(myLowVoltageSchemeDto.getWireModel220V());
        myLowVoltageSchemeBean.setTransformerModel(myLowVoltageSchemeDto.getTransformerModel());

        myLowVoltageSchemeBean.setFlatGround(myLowVoltageSchemeDto.getFlatGround()); //">平地</string>
        myLowVoltageSchemeBean.setHillyArea(myLowVoltageSchemeDto.getHillyArea()); //"山地</string>
        myLowVoltageSchemeBean.setHighMountain(myLowVoltageSchemeDto.getHighMountain()); //"高山</string>
        myLowVoltageSchemeBean.setHills(myLowVoltageSchemeDto.getHills()); //"丘陵</string>

        myLowVoltageSchemeBean.setCommonSoil(myLowVoltageSchemeDto.getCommonSoil()); //">普通土</string>
        myLowVoltageSchemeBean.setHardSoil(myLowVoltageSchemeDto.getHardSoil()); //"坚土</string>
        myLowVoltageSchemeBean.setLooseSandstone(myLowVoltageSchemeDto.getLooseSandstone()); //"松砂石</string>
        myLowVoltageSchemeBean.setMudPuddle(myLowVoltageSchemeDto.getMudPuddle()); //"泥水坑</string>
        myLowVoltageSchemeBean.setRock(myLowVoltageSchemeDto.getRock()); //"岩石</string>
        myLowVoltageSchemeBean.setTypicalDesignModel(myLowVoltageSchemeDto.getTypicalDesignModel()); //"典型设计模块</string>

        myLowVoltageSchemeBean.setUserName(myLowVoltageSchemeDto.getUserName());
        return myLowVoltageSchemeBean;
    }

    private MyLowVoltageSchemeDto lowBeanConverterToDto(MyLowVoltageSchemeBean myLowVoltageSchemeBean)
    {
        MyLowVoltageSchemeDto myLowVoltageSchemeDto = new MyLowVoltageSchemeDto() ;
        myLowVoltageSchemeDto.setId(myLowVoltageSchemeBean.getSchemeId());
        myLowVoltageSchemeDto.setSchemeUUID(myLowVoltageSchemeBean.getSchemeUUID());
        myLowVoltageSchemeDto.setSchemeName(myLowVoltageSchemeBean.getSchemeName());
        myLowVoltageSchemeDto.setWireModel380V(myLowVoltageSchemeBean.getWireModel380V());
        myLowVoltageSchemeDto.setWireModel220V(myLowVoltageSchemeBean.getWireModel220V());
        myLowVoltageSchemeDto.setTransformerModel(myLowVoltageSchemeBean.getTransformerModel());

        myLowVoltageSchemeDto.setFlatGround(myLowVoltageSchemeBean.getFlatGround()); //">平地</string>
        myLowVoltageSchemeDto.setHillyArea(myLowVoltageSchemeBean.getHillyArea()); //"山地</string>
        myLowVoltageSchemeDto.setHighMountain(myLowVoltageSchemeBean.getHighMountain()); //"高山</string>
        myLowVoltageSchemeDto.setHills(myLowVoltageSchemeBean.getHills()); //"丘陵</string>

        myLowVoltageSchemeDto.setCommonSoil(myLowVoltageSchemeBean.getCommonSoil()); //">普通土</string>
        myLowVoltageSchemeDto.setHardSoil(myLowVoltageSchemeBean.getHardSoil()); //"坚土</string>
        myLowVoltageSchemeDto.setLooseSandstone(myLowVoltageSchemeBean.getLooseSandstone()); //"松砂石</string>
        myLowVoltageSchemeDto.setMudPuddle(myLowVoltageSchemeBean.getMudPuddle()); //"泥水坑</string>
        myLowVoltageSchemeDto.setRock(myLowVoltageSchemeBean.getRock()); //"岩石</string>
        myLowVoltageSchemeDto.setTypicalDesignModel(myLowVoltageSchemeBean.getTypicalDesignModel()); //"典型设计模块</string>

        myLowVoltageSchemeDto.setUserName(myLowVoltageSchemeBean.getUserName());
        return myLowVoltageSchemeDto;
    }

    private void updateHighUI(Iterable<MyHighVoltageSchemeBean> myHighVoltageSchemeBeansIterable)
    {

        if (this.lvHighVoltage == null)
        {
            return;
        }
        List<MyHighVoltageSchemeBean> myHighVoltageSchemeBeans = Lists.newArrayList(myHighVoltageSchemeBeansIterable);
        this.myHighVoltageSchemeBeanList = myHighVoltageSchemeBeans;
        MySchemeActivity.myHighVoltageSchemeBeanList = this.myHighVoltageSchemeBeanList;
        String[] schemeNames = new String[myHighVoltageSchemeBeans.size()];
        for (int i = 0; i < myHighVoltageSchemeBeans.size(); i++) {
            schemeNames[i] = myHighVoltageSchemeBeans.get(i).getSchemeName();
        }
        if (schemeNames.length > 0) {
            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, schemeNames);
            lvHighVoltage.setAdapter(arrayAdapter);
        }
    }

    private void updateLowUI(Iterable<MyLowVoltageSchemeBean> myLowVoltageSchemeBeanIterable)
    {
        if (this.lvLowVoltage ==null)
        {
            return;
        }
        List<MyLowVoltageSchemeBean> myLowVoltageSchemeBeans = Lists.newArrayList(myLowVoltageSchemeBeanIterable);
        this.myLowVoltageSchemeBeanList = myLowVoltageSchemeBeans;
        MySchemeActivity.myLowVoltageSchemeBeanList = this.myLowVoltageSchemeBeanList;
        String[] lowSchemeNames = new String[myLowVoltageSchemeBeans.size()];
        for (int i = 0; i < myLowVoltageSchemeBeans.size(); i++) {
            lowSchemeNames[i] = myLowVoltageSchemeBeans.get(i).getSchemeName();
        }
        if (lowSchemeNames.length > 0) {
            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, lowSchemeNames);
            lvLowVoltage.setAdapter(arrayAdapter);
        }
    }




}
